home *** CD-ROM | disk | FTP | other *** search
- /* strncat.c From TC Bible page 288 Use strncat to concatenate a specified
- number of characters of one string to another. */
-
- #include <stdio.h>
- #include <string.h>
- char result[40] = "a";
- char rest[] = "bcdefghijklmnopqrstuvwxyz";
- unsigned length = sizeof(rest)/sizeof(char);
- main()
- {
- unsigned i;
- for(i = 0;i<length;i++, result[1]='\0')
- {
- strncat(result, rest, i);
- printf("%s\n", result); /* Show the current result */
- }
- }